<extend name="Public/layout" />
<block name="body">
    <link rel="stylesheet" href="/Public/Wap/css/e.css">
    <link rel="stylesheet" href="/Public/Wap/css/plist.css">
    <script src="/Public/Wap/js/vue.js"></script>
    <script src="/Public/Wap/js/e.js"></script>
    <div id="app" class="panel panel-default panel-intro">
        <div class="panel-heading">
            <ul class="nav nav-tabs" data-field="warping">
                <li class="active"><a>自有活动</a></li>
            </ul>
        </div>
        <div class="panel-body">
            <div>
                <!-- <div class="title">
                    <img src="/Public/img/gz.png" alt=""> <span>自有活动</span>
                </div> -->
                <el-form :model="ruleForms" ref="ruleForms" label-width="100px" style="padding-top: 10px;" size="small"
                    class="demo-ruleForm">
                    <el-row class="item-top top">
                        <el-col :span="4">
                            <el-form-item label="活动ID">
                                <el-input v-model="ruleForms.taobao_act_id"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="4">
                            <el-form-item label="活动标题">
                                <el-input v-model="ruleForms.activity_title"></el-input>
                            </el-form-item>
                        </el-col>
                        <!-- <el-col :span="4">
                            <el-form-item label="活动场景">
                                <el-input v-model="ruleForms.name"></el-input>
                            </el-form-item>
                        </el-col> -->
                        <el-col :span="4">
                            <el-form-item label="员工">
                                <el-select v-model="ruleForms.mid" clearable placeholder="请选择" style="width:100%">
                                    <el-option v-for="item in userList" :key="item.uid" :label="item.nickname"
                                        :value="item.uid">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                        </el-col>
                        <el-col :offset='1' :span="5"> &nbsp;&nbsp;&nbsp;&nbsp;<el-button type="primary"
                                @click="on_Submit" size="small">查询</el-button>
                            <el-button type="primary" @click="onclear" size="small">清空</el-button>
                        </el-col>
                    </el-row>
                </el-form>
                <div style="padding: 10px 10px;" id="toolbar" class="toolbar">
                    <a @click="lists(1)" title="刷新" class="btn btn-primary btn-refresh">
                        <i class="fa fa-refresh"></i></a>
                </div>
                <div class="list">
                    <el-table :data="list" stripe style="width: 100%">
                        <el-table-column prop="" label="" width="20">
                        </el-table-column>
                        <el-table-column prop="taobao_act_id" label="活动ID" width="90">
                        </el-table-column>
                        <el-table-column class="ui-nowrap-2 act-title" prop="activity_title" label="活动标题">
                        </el-table-column>
                        <el-table-column prop="start_time" label="开始时间">
                        </el-table-column>
                        <el-table-column prop="end_time" label="结束时间">
                        </el-table-column>
                        <el-table-column prop="yugu_money" label="备注">
                        </el-table-column>
                        <el-table-column prop="activityStatus_label" label="活动状态">
                        </el-table-column>
                        <el-table-column prop="m_nickname" label="所有者">
                        </el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <p class="csbtn" v-if="scope.row.allot == 2"
                                    @click="dialogVisible_hb_btn(scope.row.id)">分配</p>
                                <p class="csbtn" @click="to_mylist(scope.row.taobao_act_id)">报名商品</p>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
                <el-dialog :visible.sync="dialogVisible_hb" width="60%">
                    <div class="lg-title">分配</div>
                    <div class="form-con">
                        <el-form :rules="rules" ref="ruleForm_bd" label-width="100px" class="demo-ruleForm">
                            <el-form-item label="绑定店主：" style="margin-top: 30px;">
                                <el-select v-model="region" placeholder="请选择员工" style="width: 100%;">
                                    <el-option :label="item.nickname" :value="item.uid"
                                        v-for="(item, index) in region_list">
                                    </el-option>
                                </el-select>
                            </el-form-item>
                            <div class="btnf" style=" padding-bottom: 20px ;">
                                <el-button class="fr" type="primary" @click="submitForm_bd">确定</el-button>
                            </div>
                        </el-form>
                    </div>
                </el-dialog>
                <div class="page" style="padding-top: 20px;">
                    <p class="text fl">每页显示10条，共{{page_count}}条</p>
                    <div class="fr">
                        <el-pagination background @current-change='check' :current-page.sync="currentPage3"
                            layout="prev, pager, next" :total=page_count>
                        </el-pagination>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        new Vue({
            el: '#app',
            data() {
                return {
                    ruleForms: {
                        taobao_act_id: '',
                        activity_title: '',
                        mid: ''
                    },
                    currentPage3: 1,
                    region: '',
                    dialogVisible_hb: false,
                    page_count: 0,
                    rules: {},
                    region_list: [],
                    userList: [],
                    list: [{
                        date: '2016-05-02',
                        name: '王小虎',
                        address: '上海市普陀区金沙江路 1518 弄'
                    }, {
                        date: '2016-05-04',
                        name: '王小虎',
                        address: '上海市普陀区金沙江路 1517 弄'
                    }, {
                        date: '2016-05-01',
                        name: '王小虎',
                        address: '上海市普陀区金沙江路 1519 弄'
                    }, {
                        date: '2016-05-03',
                        name: '王小虎',
                        address: '上海市普陀区金沙江路 1516 弄'
                    }],
                }
            },
            mounted() {
                this.lists(1)
                this.binderList()
                this.getUserList();
            },
            methods: {
                getUserList() {
                    let that = this;
                    $.post(`/kcadmin/Jd/binderList`, {}, res => {
                        that.userList = res.data;
                    })
                },
                binderList() {
                    $.post(`/kcadmin/Jd/binderList`, {}, res => {
                        this.region_list = res.data
                    })
                },
                // 换绑确定
                submitForm_bd(e) {
                    let data = {
                        mid: this.region,
                        id: this.id
                    }
                    $.post(`/kcadmin/Jd/bindSeller`, data, res => {
                        if (res.code == 1) {
                            this.$message({
                                message: res.msg,
                                type: 'success'
                            });
                        } else {
                            this.$message.error(res.msg);
                        }
                        this.dialogVisible_hb = false
                        this.lists(1)

                    })
                },
                // 换绑
                dialogVisible_hb_btn(e) {
                    console.log(e)
                    this.dialogVisible_hb = true
                    this.id = e
                },
                onSubmit() {
                    // if(this.ruleForms.id == '' && this.ruleForms.name == ''){
                    //     this.$message.error('请输入查询内容');
                    //     return 
                    // }
                    this.lists(1)
                    this.currentPage3 = 1
                },
                to_mylist(id) {
                    console.log(id)
                    window.location.href = `/kcadmin/new/mylist?id=${id}`

                },
                resetForm(formName) {
                    this.ruleForms = {}
                },
                check(i) {
                    console.log('222', i)
                    this.lists(i)
                },
                lists(page) {
                    let data = {
                        page_num: page,
                        page_size: 10,
                    }

                    let postData = Object.assign(data, this.ruleForms)
                    $.post(`/kcadmin/Jd/activityList`, postData, res => {
                        this.list = res.data
                        this.page_count = parseInt(res.page_count)
                        console.log(res)
                    })
                },
                onclear() {
                    this.ruleForms = {}
                },
                on_Submit() {

                    this.lists(1)
                },
            }
        })
    </script>
    <!-- <link rel="stylesheet" href="./css.css"> -->
    <style>
        .content-wrapper .content-top {
            display: none;
        }

        .fl {
            float: left;
        }

        .fr {
            float: right;
        }

        .title {
            line-height: 98px;
            font-weight: 800;
            font-size: 18px;
            margin: 0 60px;
            position: relative;
        }

        .csbtn {
            background: #409EFF;
            width: 100px;
            text-align: center;
            color: #fff;
        }

        .el-table .cell {
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2
        }

        .lg-title {
            width: 100%;
            height: 65px;
            line-height: 65px;
            position: absolute;
            top: 0;
            left: 0;
            background: #4A90E2;
            text-indent: 25px;
            color: #fff;
            font-size: 18px;
        }

        .title img {
            width: 22px;
            height: 22px;
            margin-top: 12px;
            margin-right: 16px;
            position: absolute;
            top: 26px;
            left: -36px;
        }

        .list {
            /* margin: 0 60px 30px 60px; */
            border: 1px solid #f3f3f3
        }

        .page {
            margin: 0 50px 0 60px;
            font-size: 14px;
            color: #DB2121;
        }

        .el-form-item_s {
            margin-top: 20px;
        }
    </style>
</block>